package com.test.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author:huang
 * @Date: Created in 2021/5/14 11:22
 */
@Controller
@RequestMapping("/b")
public class ResufulController {

    //@RequestMapping(value = "/hello/{a}/{b}",method = RequestMethod.GET)
    @GetMapping("/hello1/{a}/{b}")
    public String hello(@PathVariable int a, @PathVariable int b , Model model, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //request.getRequestDispatcher("/WEB-INF/jsp/hello.jsp").forward(request,response);
        //response.sendRedirect("/index.jsp");
        model.addAttribute("msg","小婷婷"+ a + b);
        return "redirect:/index.jsp";

    }
    @PostMapping("/t1")
    public String test(String name, Model model){

        model.addAttribute("msg",name);
        return "hello";
    }
}
